/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.marlboroug.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;


@Entity
@Table(name = "Authors")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Authors.findAll", query = "SELECT a FROM Authors a"),
    @NamedQuery(name = "Authors.findByIDauthors", query = "SELECT a FROM Authors a WHERE a.iDauthors = :iDauthors"),
    @NamedQuery(name = "Authors.findByName", query = "SELECT a FROM Authors a WHERE a.name = :name")})
public class Authors implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_authors")
    private Long iDauthors;
    @Size(max = 45)
    @Column(name = "name")
    private String name;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idAuthors")
    private Collection<Articlesbyauthors> articlesbyauthorsCollection;

    public Authors() {
    }

    public Authors(Long iDauthors) {
        this.iDauthors = iDauthors;
    }

    public Long getIDauthors() {
        return iDauthors;
    }

    public void setIDauthors(Long iDauthors) {
        this.iDauthors = iDauthors;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @XmlTransient
    public Collection<Articlesbyauthors> getArticlesbyauthorsCollection() {
        return articlesbyauthorsCollection;
    }

    public void setArticlesbyauthorsCollection(Collection<Articlesbyauthors> articlesbyauthorsCollection) {
        this.articlesbyauthorsCollection = articlesbyauthorsCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (iDauthors != null ? iDauthors.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Authors)) {
            return false;
        }
        Authors other = (Authors) object;
        if ((this.iDauthors == null && other.iDauthors != null) || (this.iDauthors != null && !this.iDauthors.equals(other.iDauthors))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.marlboroug.entity.Authors[ iDauthors=" + iDauthors + " ]";
    }
    
}
